package com.jeeplus.modules.api.utils;


import com.google.gson.Gson;
import com.kuaidi100.sdk.api.QueryTrack;
import com.kuaidi100.sdk.core.IBaseClient;
import com.kuaidi100.sdk.request.QueryTrackParam;
import com.kuaidi100.sdk.request.QueryTrackReq;
import com.kuaidi100.sdk.utils.SignUtils;
import net.sf.json.JSONObject;

public class KuaidiService {

	private static final String customer = "0CC913F201A67D8BC753CD64D91C0EA4";//
	private static final String key = "nwuTDXAW3625";//
	
	public static JSONObject getKuaidi(String expressCode,String expressNo,String phone) throws Exception {
		QueryTrackReq queryTrackReq = new QueryTrackReq();
        QueryTrackParam queryTrackParam = new QueryTrackParam();
        queryTrackParam.setCom(expressCode);
        queryTrackParam.setNum(expressNo);
        queryTrackParam.setPhone(phone);
        String param = new Gson().toJson(queryTrackParam);
        queryTrackReq.setParam(param);
        queryTrackReq.setCustomer(customer);
        queryTrackReq.setSign(SignUtils.querySign(param ,key,customer));
        IBaseClient baseClient = new QueryTrack();
        return JSONObject.fromObject(baseClient.execute(queryTrackReq));
	}

    public static void main(String[] args) throws Exception {
        JSONObject kuaidi = getKuaidi("zhongtong", "75602564895048", "");
        System.out.println(kuaidi);
    }
	
}